<template>
  <div class="all">
    <el-container>
      <el-header>
        <img
          class="log"
          src="https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=3051527488,2799176351&fm=26&gp=0.jpg"
          alt=""
        /><img />
      </el-header>
      <el-main>
        <el-form
          :model="ruleForm"
          :rules="rules"
          ref="ruleForm"
          label-width="100px"
          class="demo-ruleForm"
        >
          <el-form-item label="用户名" prop="username">
            <el-input v-model="ruleForm.username"></el-input>
          </el-form-item>
          <el-form-item label="密码" prop="password">
            <el-input type="password" v-model="ruleForm.password"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
            <el-button @click="resetForm('ruleForm')">重置</el-button>
          </el-form-item>
        </el-form>
      </el-main>
    </el-container>
  </div>
</template>

<script>
// import axios from "axios";
// axios.defaults.withCredentials = true

export default {
  name: `login`,
  data () {
    return {
      ruleForm: {
        username: ``,
        password: ``
      },
      rules: {
        username: [
          { required: true, message: `请输入用户名`, trigger: `blur` },
          { min: 3, max: 5, message: `长度在 3 到 5 个字符`, trigger: `blur` }
        ],
        password: [
          { required: true, message: `请输入密码`, trigger: `change` }
        ]
      }
    }
  },
  methods: {
    submitForm (formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert(`submit!`)
        } else {
          console.log(`error submit!!`)
          return false
        }
      })
    },
    resetForm (formName) {
      this.$refs[formName].resetFields()
    }
  }
}
</script>

<style scoped>
.el-header, .el-footer {
  margin-top: 60px;
  background-color: #ffffff;
  color: #333;
  text-align: center;
  line-height: 60px;
}
.el-aside {
  background-color: #ffffff;
  color: #333;
  text-align: center;
  line-height: 200px;
}
.el-main {
  background-color: #ffffff;
  color: #333;
  text-align: center;
  line-height: 160px;
}
body > .el-container {
  margin-bottom: 40px;
}
.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}
.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.log {
  height: 100%;
}
.demo-ruleForm{

  max-width: 400px;
  margin: 50px auto;
}
</style>
